/*

    This file is part of Hometree.

    Hometree is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Hometree is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with Hometree.  If not, see <http://www.gnu.org/licenses/>.

    Copyright 2011,2012 Roman Held

*/
#ifndef _HTREE_GLOBAL_HEADER_
#define _HTREE_GLOBAL_HEADER_

#include <QFlags>
#include "htrconstants.h"

namespace Htr {

  // ---------------------------------------
  typedef enum ResourceType_ {
     MimeDataType = 1,
     InvalidType
  } ResourceType;

  namespace Res {
    // ---------------------------------------
    typedef enum OpenModeFlag_ {
      NotOpen        = 0x00,
      ReadOnly       = HTR_RES_OPEN_READ,
      WriteOnly      = HTR_RES_OPEN_WRITE,
      ReadWrite      = ReadOnly | WriteOnly,
      WriteExclusive = HTR_RES_OPEN_EXCL,
      Create         = HTR_RES_OPEN_CREATE,     // Create if not open
      Persistent     = HTR_RES_OPEN_PERSISTENT, // save on shutdown
      Temporary      = HTR_RES_OPEN_TMP         // destroy on last close 
    } OpenModeFlag;
    Q_DECLARE_FLAGS(OpenMode, OpenModeFlag)
    Q_DECLARE_OPERATORS_FOR_FLAGS(OpenMode)

    // ---------------------------------------
    typedef enum State_ {
      StUndefined,
      StOffline,
      StInit,
      StIdentified,
      StReady,
      StError
    } State; 
    
    // ---------------------------------------
    typedef enum Error_ {
      ErrOccupied = 1
    } Error; 
  };

  namespace Net {

    // ---------------------------------------
    // Meldungen zwischen Client und Server
    typedef enum ClMessageType_ {
                          // Client <-> Server:
      ClWelcomeMsg,       // C<->S 
      ClIdentMsg,         // C<- S
      ClSmsMsg,           // C<- S
      ClMonitorMsg,       // C ->S
      ClKeepAliveMsg,     // C ->S // TCP/IP-KeepAlive
      ClResourceMsg       // R<- S // Meldung fuer Ressource..
    } ClMessageType;

    // ---------------------------------------
    // Meldungen zwischen Ressourcen und Server
    typedef enum ResMessageType_ {
                     // Client <-> Server:

      // URL-Basierte Meldungen
      InitMsg,       // C<->S
   
      // ID-Basierte Meldungen
      OpenMsg,       // C ->S 
      ErrorMsg,      // C<- S
      StateMsg,      // C<- S
      CloseMsg,      // C ->S 
      UpdateMsg,     // C<->S
      MimeTypeMsg,   // C<->S
      MimeDataMsg,   // C<->S
      CreatedMsg,    // C<- S

      // Spezielle Meldungen für das Monitoring
      EventMsg,      // siehe auch enum EventType
      
      InvalidMsg
    } ResMessageType;
    
    // ---------------------------------------
    // EventMeldungen (ua. fuer Monitoring)
    typedef enum EventType_ {
      EvChanged,
      EvRemoved
    } EventType;

    // ---------------------------------------
  }; 
};

#endif
